#ifndef SHIJU_AUTO_SNIFFER_CTRL_H_INCLUDE
#define SHIJU_AUTO_SNIFFER_CTRL_H_INCLUDE

#include <string>
#include <stdint.h>
#include "eutranManager.h"
#include "BbuManager.h"

class SnifferMgr;
class AutoSnifferCtrl;

class AutoSnfStratety
{
public:
    AutoSnfStratety(std::string name);
    
    std::string getName();
    
protected:
    friend class AutoSnifferCtrl;
    bool setSnfCtrl(AutoSnifferCtrl* ptr);
    AutoSnifferCtrl* autoSnfCtrl_;
    std::string name_;

    virtual bool start(AutoSnifferCtrl*) = 0;
    virtual bool stop() = 0;
};

class AutoSnfByTime : public AutoSnfStratety
{
public:
    AutoSnfByTime();
    virtual ~AutoSnfByTime();
    bool setStartTime(uint16_t day, uint8_t hour, uint8_t min);
    
private:
    friend class AutoSnifferCtrl;
    friend class EutranMgr;
    friend class SnifferMgr;
    AutoSnfByTime(const AutoSnfByTime&);
    AutoSnfByTime& operator=(const AutoSnfByTime&);

    uint16_t day_;
    uint8_t hour_;
    uint8_t min_;
    uint32_t autoSnfTimer_; 
    EutranTimerElement<AutoSnfByTime> autoSnfHandler_;
    void startSniffer();

    virtual bool start(AutoSnifferCtrl*);
    virtual bool stop();
};

class AutoSnifferCtrl
{
public:
    AutoSnifferCtrl(BbuCtrl* ptr);
    bool start(AutoSnfStratety*);
    void stop();
    bool isActive();
    void indicateBbuDeactive();

private:
    friend class EutranMgr;
    friend class AutoSnfByTime;
    friend class SnifferMgr;
    AutoSnifferCtrl(const AutoSnifferCtrl&);
    AutoSnifferCtrl& operator=(const AutoSnifferCtrl&);

    AutoSnfStratety* strategy_;
    BbuCtrl* bbuPtr_;
    bool isActive_;
    void startSniffer();

    std::vector<EarfcnRangeType> arfcnRange_;

    uint32_t retrySnfTimer_; 
    EutranTimerElement<AutoSnifferCtrl> retrySnfHandler_;
    void restartSniffer();
};

#endif
